home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / boot / initrd.img-2.6.20-15-generic / initrd.img-2.6 / init
Encoding:
Text File  |  2007-05-25  |  3.1 KB  |  173 lines

  1. #!/bin/sh
  2.  
  3. echo "Loading, please wait..."
  4.  
  5. [ -d /dev ] || mkdir -m 0755 /dev
  6. [ -d /root ] || mkdir --mode=0700 /root
  7. [ -d /sys ] || mkdir /sys
  8. [ -d /proc ] || mkdir /proc
  9. [ -d /tmp ] || mkdir /tmp
  10. mkdir -p /var/lock
  11. mount -t sysfs none /sys -onodev,noexec,nosuid
  12. mount -t proc none /proc -onodev,noexec,nosuid
  13.  
  14. # Note that this only becomes /dev on the real filesystem if udev's scripts
  15. # are used; which they will be, but it's worth pointing out
  16. mount -t tmpfs -o mode=0755 udev /dev
  17. [ -e /dev/console ] || mknod /dev/console c 5 1
  18. [ -e /dev/null ] || mknod /dev/null c 1 3
  19. > /dev/.initramfs-tools
  20. mkdir /dev/.initramfs
  21.  
  22. # Export the dpkg architecture
  23. export DPKG_ARCH=
  24. . /conf/arch.conf
  25.  
  26. # Export it for root hardcoding
  27. export ROOT=
  28.  
  29. # Bring in the main config
  30. . /conf/initramfs.conf
  31. for i in conf/conf.d/*; do
  32.     [ -f ${i} ] && . ${i}
  33. done
  34. . /scripts/functions
  35.  
  36. # Parse command line options
  37. export break=
  38. export init=/sbin/init
  39. export quiet=n
  40. export readonly=y
  41. export rootmnt=/root
  42. export debug=
  43. export cryptopts=${CRYPTOPTS}
  44. export panic
  45.  
  46. for x in $(cat /proc/cmdline); do
  47.     case $x in
  48.     init=*)
  49.         init=${x#init=}
  50.         ;;
  51.     root=*)
  52.         ROOT=${x#root=}
  53.         case $ROOT in
  54.         LABEL=*)
  55.             ROOT="/dev/disk/by-label/${ROOT#LABEL=}"
  56.             ;;
  57.         UUID=*)
  58.             ROOT="/dev/disk/by-uuid/${ROOT#UUID=}"
  59.             ;;
  60.         /dev/nfs)
  61.             BOOT=nfs
  62.             ;;
  63.         esac
  64.         ;;
  65.     rootflags=*)
  66.         ROOTFLAGS="-o ${x#rootflags=}"
  67.         ;;
  68.     rootfstype=*)
  69.         ROOTFSTYPE="${x#rootfstype=}"
  70.         ;;
  71.     rootdelay=*)
  72.         ROOTDELAY="${x#rootdelay=}"
  73.         ;;
  74.     cryptopts=*)
  75.         cryptopts="${x#cryptopts=}"
  76.         ;;
  77.     nfsroot=*)
  78.         NFSROOT="${x#nfsroot=}"
  79.         ;;
  80.     netboot=*)
  81.         NETBOOT="${x#netboot=}"
  82.         ;;
  83.     ip=*)
  84.         IPOPTS="${x#ip=}"
  85.         ;;
  86.     boot=*)
  87.         BOOT=${x#boot=}
  88.         ;;
  89.     resume=*)
  90.         RESUME="${x#resume=}"
  91.         ;;
  92.     noresume)
  93.         NORESUME=y
  94.         ;;
  95.     panic=*)
  96.         panic="${x#panic=}"
  97.         ;;
  98.     quiet)
  99.         quiet=y
  100.         ;;
  101.     ro)
  102.         readonly=y
  103.         ;;
  104.     rw)
  105.         readonly=n
  106.         ;;
  107.     debug)
  108.         debug=y
  109.         exec >/tmp/initramfs.debug 2>&1
  110.         set -x
  111.         ;;
  112.     debug=*)
  113.         debug=y
  114.         set -x
  115.         ;;
  116.     break=*)
  117.         break=${x#break=}
  118.         ;;
  119.     break)
  120.         break=premount
  121.         ;;
  122.     esac
  123. done
  124.  
  125. if [ -z "${NORESUME}" ]; then
  126.     export resume=${RESUME}
  127. fi
  128.  
  129. depmod -a
  130. maybe_break top
  131.  
  132. # Don't do log messages here to avoid confusing usplash
  133. run_scripts /scripts/init-top
  134.  
  135. maybe_break modules
  136. log_begin_msg "Loading essential drivers..."
  137. load_modules
  138. log_end_msg
  139.  
  140. maybe_break premount
  141. [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/init-premount"
  142. run_scripts /scripts/init-premount
  143. [ "$quiet" != "y" ] && log_end_msg
  144.  
  145. maybe_break mount
  146. log_begin_msg "Mounting root file system..."
  147. . /scripts/${BOOT}
  148. parse_numeric ${ROOT}
  149. mountroot
  150. log_end_msg
  151.  
  152. maybe_break bottom
  153. [ "$quiet" != "y" ] && log_begin_msg "Running /scripts/init-bottom"
  154. run_scripts /scripts/init-bottom
  155. [ "$quiet" != "y" ] && log_end_msg
  156.  
  157. # Move virtual filesystems over to the real filesystem
  158. mount -n -o move /sys ${rootmnt}/sys
  159. mount -n -o move /proc ${rootmnt}/proc
  160.  
  161. while [ ! -x ${rootmnt}${init} ]; do
  162.     panic "Target filesystem doesn't have ${init}"
  163. done
  164.  
  165. # Confuses /etc/init.d/rc
  166. if [ -n ${debug} ]; then
  167.     unset debug
  168. fi
  169.  
  170. # Chain to real filesystem
  171. maybe_break init
  172. exec run-init ${rootmnt} ${init} "$@" <${rootmnt}/dev/console >${rootmnt}/dev/console
  173.